package com.fl.nj.service.impl;

import com.fl.nj.entity.SystemConfig;
import com.fl.nj.mapper.SystemConfigMapper;
import com.fl.nj.service.SystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 系统配置Service实现类
 */
@Service
public class SystemConfigServiceImpl implements SystemConfigService {

    @Autowired
    private SystemConfigMapper systemConfigMapper;

    @Override
    public List<SystemConfig> findAll() {
        return systemConfigMapper.findAll();
    }

    @Override
    public SystemConfig findById(Long id) {
        return systemConfigMapper.findById(id);
    }

    @Override
    public SystemConfig findByConfigKey(String configKey) {
        return systemConfigMapper.findByConfigKey(configKey);
    }

    @Override
    public int insert(SystemConfig systemConfig) {
        Date now = new Date();
        systemConfig.setCreateTime(now);
        systemConfig.setUpdateTime(now);
        return systemConfigMapper.insert(systemConfig);
    }

    @Override
    public int update(SystemConfig systemConfig) {
        systemConfig.setUpdateTime(new Date());
        return systemConfigMapper.update(systemConfig);
    }

    @Override
    public int delete(Long id) {
        return systemConfigMapper.delete(id);
    }
}